#include <cstdio>
#include <cstring>
int main()
{
    char str[1001] = {0};
    char c;
    int i = 0, j, k;
    while ((c = getchar()) != '\n')
        str[i++] = c;
    int len = strlen(str);
    int cont[1001] = {0}; //记录紧靠该字符后面相同字符的个数
    for (i = 0; i < len; ++i)
    {
        j = 0;
        do
        {
            ++cont[i];
            ++j;
        } while (str[i] == str[i + j]);
    }
    int max; //存储最长长度
    int ans = cont[0];
    for (i = 1; i < len; i += cont[i])
    {
        for (j = i - 1, k = i + cont[i], max = cont[i]; j >= 0, k < len; --j, ++k)
        {
            if (str[j] == str[k])
            {
                max += 2;
            }
            else
            {
                break;
            }
        }
        if (max > ans)
            ans = max;
    }
    printf("%d\n", ans);
    return 0;
}